<include file="public:header" />
<div class="pad-10" >
    <form id="myform" name="myform" action="{:u('items_cate/delete')}" method="post" onsubmit="return check();">
    <div class="table-list">
    <table width="100%" cellspacing="0">
        <thead>
            <tr>
            	<th width="50">ID</th>
                <th width="4%"><input type="checkbox" value="" id="check_box" onclick="selectall('id[]');"></th>
              	<th width="200">{:L('name')}</th>
                <th width="80">{:L('img')}</th>              	 
                <th width="80">商品数</th>  
                <th>匹配分类关键字</th>  
                <th width="60">{:L('ordid')}</th>
				<th width="60">{:L('recommend')}</th>
                <th width="60">{:L('is_hots')}</th>             
              	<th width="40">{:L('status')}</th>             
              	<th width="120">操作</th>
            </tr>
        </thead>
    	<tbody>
        <volist name="items_cate_list" id='val'>
        <tr class="{$val.cls} level_{$val.level}" iid="{$val.id}" pid="{$val.pid}" level="{$val.level}">
        	<td align="center">{$val.id}</td>
            <td align="center"><input type="checkbox" value="{$val.id}" name="id[]"></td>
            <td>
            	<div style="margin-left:{$val['level']*30}px">
            		
					<if condition="$val.cls neq ''">
						<img src="__ROOT__/statics/admin/images/tv-collapsable.gif" class="expandable" id="{$val.id}" pid="{$val.pid}" level="{$val.level}"/>	
					<else/>
					 	<img src="__ROOT__/statics/admin/images/tv-expandable.gif" class="expandable" id="{$val.id}" pid="{$val.pid}" level="{$val.level}"/>						 
					</if>
					
					
                   
                    <span style="color:{$val.color}; padding-left:5px;">{$val.name}</span>
                </div>            	
           	</td>
            <td>
            	<if condition="$val['img'] neq ''">
                <img src="{$val.img}" height="25px;"/>
                </if>
            </td>			
            <td align="center"></td>
            <td align="left">{$val.matching_title}</td>
            <td align="center">
            	<input type="text" class="input-text-c input-text" value="{$val.ordid}" size="4" name="listorders[{$val.id}]" id="sort_{$val.id}" onblur="sort({$val.id},'ordid',this.value)"  onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
			</td>	
			<td align="center" <if condition="$val.level eq 2">onclick="status({$val.id},'recommend')" id="recommend_{$val.id}"</if> >
				<if condition="$val.level eq 2">
					<img src="__ROOT__/statics/images/status_{$val.recommend}.gif" />
				<else/>	
					&nbsp;	
				</if>				
			</td>	
            <td align="center" onclick="status({$val.id},'is_hots')" id="is_hots_{$val.id}"><img src="__ROOT__/statics/images/status_{$val.is_hots}.gif" /></td>
            <td align="center" onclick="status({$val.id},'status')" id="status_{$val.id}"><img src="__ROOT__/statics/images/status_{$val.status}.gif" /></td>
            <td align="center"><a class="blue" href="{:u('items_cate/edit',array('id'=>$val['id']))}">编辑</a></td>
        </tr>
        </volist>
    	</tbody>
    </table>

    <div class="btn">
    <label for="check_box">全选/取消</label>
    <input type="submit" class="button" name="dosubmit" value="{$Think.lang.delete}" onclick="return confirm('{$Think.lang.sure_delete}')"/>
    
    </div>

    </div>
    </form>
</div>
<script type="text/javascript">
$(function(){
$('.expandable').toggle(
		function(){
			var id=
			$('.sub_'+$(this).attr('id')).hide();		
			$(this).attr('src',ROOT_PATH+'/statics/admin/images/tv-expandable.gif');
		},
		function(){
			$('.sub_'+$(this).attr('id')).show();
			$(this).attr('src',ROOT_PATH+'/statics/admin/images/tv-collapsable.gif');
		}
	);
});

var lang_items_cate_name = "商品分类";
function check(){
	if($("#myform").attr('action') == '{:u("items_cate/delete")}') {
		var ids='';
		$("input[name='id[]']:checked").each(function(i, n){
			ids += $(n).val() + ',';
		});

		if(ids=='') {
			window.top.art.dialog({content:lang_please_select+lang_items_cate_name,lock:true,width:'200',height:'50',time:1.5},function(){});
			return false;
		}
	}
	return true;
}
function status(id,type){
    $.get("{:u('items_cate/status')}", { id: id, type: type }, function(jsondata){
		var return_data  = eval("("+jsondata+")");
		$("#"+type+"_"+id+" img").attr('src', '__ROOT__/statics/images/status_'+return_data.data+'.gif')
	}); 
}
//排序方法
function sort(id,type,num){
    
    $.get("{:u('items_cate/sort')}", { id: id, type: type,num:num }, function(jsondata){
        
		$("#"+type+"_"+id+" ").attr('value', jsondata.data);
	},'json'); 
}
</script>
</body>
</html>